package com.hystrix.command;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * 自定义命令对象，打印信息，观察过程
 * Created by earl on 2018/4/28.
 */
public class RunCommand extends HystrixCommand<String> {

   String msg ;

    public RunCommand(String msg){
        //调用父类的构造器，设置命令组的key，默认用来作为线程池的key
        super(HystrixCommandGroupKey.Factory.asKey("commandGroup"));
        this.msg = msg;
    }

    @Override
    protected String run() throws Exception {
        System.out.println(" command run ---"+msg);
        return msg;
    }
}
